<template>
  <!--商家核销端首页-->
  <div class="content">
    <div class="header">
      <router-link to="/ziliao" tag="p"><span><img src="../../assets/userhead.png" alt="" width="66"></span>
        {{airport.airportName}}-{{employee.employeeName}}
      </router-link>
      <wv-button type="default" :mini="true" @click="goSignOut()"><img src="../../assets/tuichu.png" alt="" width="13">退出
      </wv-button>
    </div>
    <div class="saocontent" @click="goScan()">
      <img src="../../assets/sao.png" alt="" width="20">扫一扫使用验证
    </div>
    <router-link to="/shuziyanzheng">
      <wv-button type="default" :mini="true" class="btn shuzi">数字码使用验证</wv-button>
    </router-link>
    <router-link to="/jilu">
      <wv-button type="default" :mini="true" class="btn jilu">使用验证记录</wv-button>
    </router-link>
    <router-link to="/addCheck">
      <wv-button type="default" :mini="true" class="btn check">核验增减</wv-button>
    </router-link>
    <div class="des">
      <p class="title">使用说明</p>
      <ul>
        <li><p>第一种 </p>1.点击“扫一扫使用验证”——扫描会员出示的要使用的相应服务对应的二维码</li>
        <li><p>第二种 </p>1.点击“数字码使用验证”——输入会员出示的要使用的相应服务对应的二维码下方的数字码。</li>
      </ul>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import {getuserInfo, employeeAppVersion, checkAccountGoods} from '../../../test/unit/http'
  import {wxApi} from '../../../test/unit/flyme_weixin'
  import {Toast} from 'we-vue'

  export default {
    name: '',
    props: {},
    data() {
      return {
        airport: {},
        employee: {}
      };
    },
    methods: {
      goSignOut() {
        window.localStorage.clear();
        this.$router.push({path: '/'})
      },
      goScan() {
        let that = this;
        that.$router.push("scan")
      },
      getData(params) {
        checkAccountGoods(params).then(res => {
          console.log(res);
          if (res.code === 100) {
            let accountGoods = res.object;
            if (accountGoods.isVipCard == 1) {
              this.$router.push({name: 'yanzheng', query: {'accountGoodsId': accountGoods.accountGoodsId}})
            } else {
              this.$router.push({name: 'danci', query: {'accountGoodsId': accountGoods.accountGoodsId}})
            }
          } else {
            Toast.fail(res.info);
          }
        })
      },
      getUserInfoData() {
        getuserInfo().then(res => {
          console.log(res);
          if (res.code == 100) {
            this.airport = res.object.airport;
            this.employee = res.object.employee;
            this.userhead = res.object.userhead;
          }
        })
      },
      checkUpdate() {
        plus.runtime.getProperty(plus.runtime.appid, function (wgtInfo) {
          console.log("wgtInfo版本信息version" + wgtInfo.version);
          let version = wgtInfo.version;
          employeeAppVersion({'versionCode':'sijiguibin'}).then((res) => {
            let appPath = res.object.url;
            let versionNo = res.object.versionNo;
            if (version != versionNo && appPath) {
              plus.nativeUI.confirm("应用有新版本，是否立即下载更新？", function (event) {
                if (event.index == 0) {
                  plus.nativeUI.showWaiting("下载更新文件中...");
                  plus.downloader.createDownload(appPath, {}, function (d, status) {
                    if (status == 200) { // 下载成功
                      let path = d.filename;
                      console.log(d.filename);
                      plus.runtime.install(path);
                    } else {
                      plus.nativeUI.alert("下载更新文件失败！");
                    }
                    plus.nativeUI.closeWaiting();
                  }).start();
                }
              }, '更新程序', ['确认']);
            }
          });
        });
      }
    },
    created() {
      wxApi.init();
      this.getUserInfoData();
      this.checkUpdate();
    },
    mounted() {
    },
    components: {}
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .content {
    height: 100vh;
    background-image: linear-gradient(to right, #fea538, #f27140);
    padding: 10px;

    .header {
      display: flex;
      color: #fff;
      font-size: 15px;
      margin-bottom: 20px;

      p {
        text-align: left;
        flex: 0 73%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;

        span {
          display: inline-block;
          border-radius: 50%;
          background-color: rgba(255, 255, 255, 0.4);
          padding: 5px;
          width: 66px;
          height: 66px;
          margin-right: 10px;
        }

        img {
          border-radius: 50%;
          vertical-align: middle;

        }

      }

      button {
        border-radius: 25px;
        color: #f88d3b;
        height: 33px;
        line-height: 33px;
        margin-top: 19px;

        img {
          vertical-align: sub;
          margin-right: 5px;
        }
      }
    }

    .saocontent {
      background-color: #fff;
      border-radius: 5px;
      margin: auto;
      padding: 11px;
      font-size: 18px;
      color: #f98e3c;

      img {
        margin-right: 15px;
        vertical-align: sub;
      }
    }

    .des {
      background-color: rgba(255, 255, 255, 0.6);
      border-radius: 5px;
      padding: 20px 10px;
      margin: auto;
      margin-top: 15px;

      .title {
        font-size: 20px;
        color: #f98e3c;
        margin-bottom: 10px;
      }

      ul {
        li {
          color: #666;
          font-size: 15px;
          line-height: 25px;
          text-align: left;

          p {
            color: #111;
          }
        }

      }
    }

    .btn {
      height: 50px;
      line-height: 50px;
      font-size: 17px;
      width: calc(50% - 10px);
      margin-top: 15px;
    }

    .shuzi {
      color: #f98e3c;
      margin-right: 15px;
    }

    .jilu {
      border: 1px solid #fff;
      color: #f98e3c;
    }

    .check {
      color: #f98e3c;
      margin-right: 15px;
    }

    .shoukuan {
      background-image: linear-gradient(to right, #fea538, #f27140);
      height: 100vh;
      padding: 20px 10px;
    }
  }
</style>
